// const importers = import.meta.glob<string>( './i18n/lang/*.ts')
//
//
// const languages: { [key in string]: () => any } = {}
//
// // import './i18n/lang/*/*.ts'
// Object.keys(importers).forEach((fileName) => {
//
//     const language = fileName.replace('./i18n/lang/', '').replace('.ts', '')
//     languages[language] = importers[fileName]
// })
// //eg:{{语言名称：import函数},{},...}
// export default languages


import {computed} from "vue";

export type JudgeType = {
    status: number;
    name: string;
    short?: string;
    type?: string;
    rgb?: string;
};

export const Judge = {
    STATUS_NOT_SUBMITTED: { status: -10, name: "Not Submitted",  type: 'info', rgb:'#909399' },
    STATUS_CANCELLED: { status: -4, name: "Cancelled" , type: 'info', rgb:'#676fc1'},
    STATUS_PRESENTATION_ERROR: { status: -3, name: "Presentation Error" },
    STATUS_COMPILE_ERROR: { status: -2, name: "Compile Error", type: 'warning', rgb:'#f90'},
    STATUS_WRONG_ANSWER: { status: -1, name: "Wrong Answer" ,type: 'error', rgb:'#ed3f14'},
    STATUS_ACCEPTED: { status: 0, name: "Accepted",type: 'success', rgb:'#19be6b'},
    STATUS_TIME_LIMIT_EXCEEDED: { status: 1, name: "Time Limit Exceeded" ,type: 'error', rgb:'#ed3f14'},
    STATUS_MEMORY_LIMIT_EXCEEDED: { status: 2, name: "Memory Limit Exceeded" , type: 'error', rgb:'#ed3f14'},
    STATUS_RUNTIME_ERROR: { status: 3, name: "Runtime Error" , type: 'error', rgb:'#ed3f14'},
    STATUS_SYSTEM_ERROR: { status: 4, name: "System Error" ,type: 'info', rgb:'#909399'},
    STATUS_PENDING: { status: 5, name: "Pending", type: 'warning', rgb:'#f90' },
    STATUS_COMPILING: { status: 6, name: "Compiling" , type: 'info', rgb:'#25bb9b'},
    STATUS_JUDGING: { status: 7, name: "Judging", type: 'info', rgb:'#2d8cf0' },
    STATUS_PARTIAL_ACCEPTED: { status: 8, name: "Partial Accepted" },
    STATUS_SUBMITTING: { status: 9, name: "Submitting" ,type: 'warning', rgb:'#f90'},
    STATUS_SUBMITTED_FAILED: { status: 10, name: "Submitted Failed" },
    STATUS_NULL: { status: 15, name: "No Status" ,type: 'info', rgb:'#909399',}
} as const;

export function getTypeByStatus(status: number): JudgeType {
    for (const key of Object.keys(Judge)) {
        if (Judge[key as keyof typeof Judge].status === status) {
            return Judge[key as keyof typeof Judge];
        }
    }
    return Judge.STATUS_NULL;
}

export const judgeStatusList = Object.values(Judge);

export const JUDGE_STATUS  = {
    '-10': {
        title: 'Not Submitted',
        short: 'NS',
        color: 'gray',
        type: 'info',
        rgb:'#909399'
    },
    '-5': {
        name: 'Submitted Unknown Result',
        short: 'SNR',
        color: 'gray',
        type: 'info',
        rgb:'#909399'
    },
    '-4': {
        name: 'Cancelled',
        short: 'CA',
        color: 'purple',
        type: 'info',
        rgb:'#676fc1'
    },
    '-3': {
        name: 'Presentation Error',
        short: 'PE',
        color: 'yellow',
        type: 'warning',
        rgb:'#f90'
    },
    '-2': {
        name: 'Compile Error',
        short: 'CE',
        color: 'yellow',
        type: 'warning',
        rgb:'#f90'
    },
    '-1': {
        name: 'Wrong Answer',
        short: 'WA',
        color: 'red',
        type: 'error',
        rgb:'#ed3f14'
    },
    '0': {
        name: 'Accepted',
        short: 'AC',
        color: 'green',
        type: 'success',
        rgb:'#19be6b'
    },
    '1': {
        name: 'Time Limit Exceeded',
        short: 'TLE',
        color: 'red',
        type: 'error',
        rgb:'#ed3f14'
    },
    '2': {
        name: 'Memory Limit Exceeded',
        short: 'MLE',
        color: 'red',
        type: 'error',
        rgb:'#ed3f14'
    },
    '3': {
        name: 'Runtime Error',
        short: 'RE',
        color: 'red',
        type: 'error',
        rgb:'#ed3f14'
    },
    '4': {
        name: 'System Error',
        short: 'SE',
        color: 'gray',
        type: 'info',
        rgb:'#909399'
    },
    '5': {
        name: 'Pending',
        color: 'yellow',
        type: 'warning',
        rgb:'#f90'
    },
    '6':{
        name: 'Compiling',
        short: 'CP',
        color: 'green',
        type: 'info',
        rgb:'#25bb9b'
    },
    '7': {
        name: 'Judging',
        color: 'blue',
        type: '',
        rgb:'#2d8cf0'
    },
    '8': {
        name: 'Partial Accepted',
        short: 'PAC',
        color: 'blue',
        type: '',
        rgb:'#2d8cf0'
    },
    '9': {
        name: 'Submitting',
        color: 'yellow',
        type: 'warning',
        rgb:'#f90'
    },
    '10':{
        name:"Submitted Failed",
        color:'gray',
        short:'SF',
        type: 'info',
        rgb:'#909399',
    }
}


type enumItem =  {
    value : number | string,
    label : any
}

export const getLabelByValue = function (list : Array<enumItem> , value : number | string) : any{
    return list.filter(item => item.value == value)[0]?.label || ''
}
export const AUTH = [
    {
      value:0,
      label:"公有",
    },
    {
        value:1,
        label:"私有",
    }
] as Array<enumItem>

export const STATUS = [
    {
        value:0,
        label:"正常",
    },
    {
        value:1,
        label:"禁用",
    }
]

export const COMPETITION_TYPE = [
    {
        value:0,
        label:"ACM",
    },
    {
        value:1,
        label:"IOI",
    }
] as Array<enumItem>

export const COMPETITION_AUTH = [
    {
        value:0,
        label:"公开赛",
    },
    {
        value:1,
        label:"私有赛",
    }
]

export const COMPETITION_STATUS = [
    {
        value:0,
        label:"未开始",
    },
    {
        value:1,
        label:"进行中",
    },
    {
        value:2,
        label:"已结束",
    }
] as Array<enumItem>

export const ARTICLE = {
    // 1公开 2私密 3草稿
    auth : [
        {
            value: 1,
            label: "公开"
        },
        {
            value : 2,
            label : "私密"
        },
        {
            value : 3,
            label : "草稿"
        }
    ] as Array<enumItem>,
//是否开启评论
    isComment : [
        {
            value: 0,
            label: "否"
        },
        {
            value : 1,
            label : "是"
        },

    ] as Array<enumItem>

}

export const PROBLEM = {
    auth : [
        {
            value: 0,
            label: "公开"
        },
        {
            value : 1,
            label : "私密"
        },
        {
            value : 2,
            label : "比赛"
        }
    ] as Array<enumItem>,
}
